package com.lhc.listener;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MessageLnstener {
//    @RabbitListener(queuesToDeclare = @Queue(value = "hello"))
//    public void getMessage01(String message){
//        System.out.println("okokok"+message);
//    }

//    @RabbitListener(queuesToDeclare = @Queue(value = "queen_work02"))
//    public void getMessage01(String message){
//        System.out.println("这是消息1:"+message);
//    }
//    @RabbitListener(queuesToDeclare = @Queue(value = "queen_work02"))
//    public void getMessage02(String message){
//        System.out.println("这是消息2:"+message);
//    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,
            key = {"user.*"},
            exchange = @Exchange(value = "routing-topic",type = "topic")
    ))
    public void getMessage01(String message){
        System.out.println("message1"+message);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,
            key = {"user.#"},
            exchange = @Exchange(value = "routing-topic",type = "topic")
    ))
    public void getMessage02(String message){
        System.out.println("message02"+message);
    }
}
